﻿//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Ext.h".
//-------------------------------------------------------------------

#ifndef _UXS_CL_ENUMS_H
#define _UXS_CL_ENUMS_H

#pragma once

#include "../opencl.h"

namespace UX_STL
{
namespace CLShell
{
	using namespace UXTypesExt;
	using namespace UXMath;


// -------------------------- Device Type ------------------------ //

namespace cl_device
{
	enum	type	:	::cl_device_type
	{
		UNKNOWN		= 0,
		DEFAULT		= CL_DEVICE_TYPE_DEFAULT,
		CPU			= CL_DEVICE_TYPE_CPU,
		GPU			= CL_DEVICE_TYPE_GPU,
		ACCELERATOR	= CL_DEVICE_TYPE_ACCELERATOR,
		ALL			= CL_DEVICE_TYPE_ALL,
	};
}


// ------------------------ Queue Properties --------------------- //

namespace cl_queue_property
{
	enum	type	: ::cl_command_queue_properties
	{
		NONE					= 0,
		OUT_OF_ORDER_EXEC_MODE	= CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
		PROFILING				= CL_QUEUE_PROFILING_ENABLE,
		_INIT					= 0,
	};
}


// --------------------- Program Build Options ------------------- //

namespace cl_prog_options
{
	enum	type	: uint32
	{
		// Math Intrinsics Options //
		MATH_SINGLE_PRECISION_CONST	= 0x00000001,	//-cl-single-precision-constant
		MATH_DENORMS_ARE_ZERO		= 0x00000002,	//-cl-denorms-are-zero
		_MATH_MASK					= 0x000000FF,

		// Optimization Options //
		OPT_DISABLE					= 0x00000100,	//-cl-opt-disable
		OPT_STRICT_ALIASING			= 0x00000200,	//-cl-strict-aliasing
		OPT_MAD_ENABLE				= 0x00000400,	//-cl-mad-enable
		OPT_NO_SIGNED_ZEROS			= 0x00000800,	//-cl-no-signed-zeros
		OPT_UNSAFE_MATH				= 0x00001000,	//-cl-unsafe-math-optimizations
		OPT_FINITE_MATH_ONLY		= 0x00002000,	//-cl-finite-math-only
		OPT_FAST_RELAXED_MATH		= 0x00003000,	//-cl-fast-relaxed-math == -cl-finite-math-only & -cl-unsafe-math-optimizations
		_OPT_MASK					= 0x0000FF00,

		// Options to Request or Suppress Warnings //
		NO_WARNING					= 0x00100000,	//-w
		WARNING_AS_ERROR			= 0x00200000,	//-Werror
		_W_MASK						= 0x00F00000,

		// Options Controlling the OpenCL C Version //
		CL_1_0						= 0x10000000,	//-cl-std=CL1.0
		CL_1_1						= 0x20000000,	//-cl-std=CL1.1
		_CL_VER_MASK				= 0xF0000000,
	};

	UX_ENUM_BIT_OPERATIONS( type )
}


// -------------------------- Memory Flags ----------------------- //

namespace cl_memory
{
	enum	type	: ::cl_mem_flags
	{
		READ_WRITE		= CL_MEM_READ_WRITE,
		WRITE_ONLY		= CL_MEM_WRITE_ONLY,
		READ_ONLY		= CL_MEM_READ_ONLY,
		USE_HOST_PTR	= CL_MEM_USE_HOST_PTR,
		ALLOC_HOST_PTR	= CL_MEM_ALLOC_HOST_PTR,
		COPY_HOST_PTR	= CL_MEM_COPY_HOST_PTR,
		_INIT			= 0,
	};

	UX_ENUM_BIT_OPERATIONS( type )
}


// ----------------------- Image Format Flags -------------------- //

namespace cl_img_channel_order
{
	enum	type :	::cl_channel_order
	{
		R			= CL_R,
		A			= CL_A,
		RG			= CL_RG,
		RA			= CL_RA,
		RGB			= CL_RGB,
		RGBA		= CL_RGBA,
		BGRA		= CL_BGRA,
		ARGB		= CL_ARGB,
		INTENSITY	= CL_INTENSITY,
		LUMINANCE	= CL_LUMINANCE,
		Rx			= CL_Rx,
		RGx			= CL_RGx,
		RGBx		= CL_RGBx,
	};
}


namespace cl_img_channel
{
	enum	type :	::cl_channel_type
	{
		SNORM_INT8			= CL_SNORM_INT8,
		SNORM_INT16			= CL_SNORM_INT16,
		UNORM_INT8			= CL_UNORM_INT8,
		UNORM_INT16			= CL_UNORM_INT16,
		UNORM_SHORT_565		= CL_UNORM_SHORT_565,
		UNORM_SHORT_555		= CL_UNORM_SHORT_555,
		UNORM_INT_101010	= CL_UNORM_INT_101010,
		SINT8				= CL_SIGNED_INT8,
		SINT16				= CL_SIGNED_INT16,
		SINT32				= CL_SIGNED_INT32,
		UINT8				= CL_UNSIGNED_INT8,
		UINT16				= CL_UNSIGNED_INT16,
		UINT32				= CL_UNSIGNED_INT32,
		HALF				= CL_HALF_FLOAT,
		FLOAT				= CL_FLOAT,
	};
}


struct cl_img_format
{
	cl_img_channel_order::type	eOrder;
	cl_img_channel::type		eChannel;
	///
	cl_img_format(): eOrder(cl_img_channel_order::type(0)), eChannel(cl_img_channel::type(0)) {}
	cl_img_format(cl_img_channel_order::type order, cl_img_channel::type channel): eOrder(order), eChannel(channel) {}
};


// ----------------------- Addressing Mode ----------------------- //

namespace cl_addressing
{
	enum	type	: ::cl_addressing_mode
	{
		NONE			= CL_ADDRESS_NONE,
		CLAMP_TO_EDGE	= CL_ADDRESS_CLAMP_TO_EDGE,
		CLAMP			= CL_ADDRESS_CLAMP,
		REPEATE			= CL_ADDRESS_REPEAT,
		_INIT			= NONE,
	};
}


// ------------------------ Filter Mode -------------------------- //

namespace cl_filter
{
	enum	type	: ::cl_filter_mode
	{
		NEAREST		= CL_FILTER_NEAREST, 
		LINEAR		= CL_FILTER_LINEAR,
		_INIT		= NEAREST,
	};
}


// ---------------------- Event Status Type ---------------------- //

namespace cl_event_status
{
	enum	type	: ::cl_int
	{
		COMPLETE				= CL_COMPLETE,	// the command has completed
		RUNNING					= CL_RUNNING,	// device is currently executing this command
		SUBMITTED				= CL_SUBMITTED,	// enqueued command has been submitted by the host
												//   to the device associated with the command-queue
		QUEUED					= CL_QUEUED,	// command has been enqueued in the command-queue
		
		// QUEUED + 1 ... -1 - error codes

		_INIT					= COMPLETE,
	};
}


// --------------------- Event Command Type ---------------------- //

namespace cl_event_command
{
	enum	type	: ::cl_command_type
	{
		NDRANGE_KERNEL			= CL_COMMAND_NDRANGE_KERNEL,
		TASK					= CL_COMMAND_TASK,
		NATIVE_KERNEL			= CL_COMMAND_NATIVE_KERNEL,
		READ_BUFFER				= CL_COMMAND_READ_BUFFER,
		WRITE_BUFFER			= CL_COMMAND_WRITE_BUFFER,
		COPY_BUFFER				= CL_COMMAND_COPY_BUFFER,
		READ_IMAGE				= CL_COMMAND_READ_IMAGE,
		WRITE_IMAGE				= CL_COMMAND_WRITE_IMAGE,
		COPY_IMAGE				= CL_COMMAND_COPY_IMAGE,
		COPY_BUFFER_TO_IMAGE	= CL_COMMAND_COPY_BUFFER_TO_IMAGE,
		COPY_IMAGE_TO_BUFFER	= CL_COMMAND_COPY_IMAGE_TO_BUFFER,
		MAP_BUFFER				= CL_COMMAND_MAP_BUFFER,
		MAP_IMAGE				= CL_COMMAND_MAP_IMAGE,
		UNMAP_MEM_OBJECT		= CL_COMMAND_UNMAP_MEM_OBJECT,
		MARKER					= CL_COMMAND_MARKER,
		ACQUIRE_GL_OBJECTS		= CL_COMMAND_ACQUIRE_GL_OBJECTS,
		RELEASE_GL_OBJECTS		= CL_COMMAND_RELEASE_GL_OBJECTS,
		READ_BUFFER_RECT		= CL_COMMAND_READ_BUFFER_RECT,
		WRITE_BUFFER_RECT		= CL_COMMAND_WRITE_BUFFER_RECT,
		COPY_BUFFER_RECT		= CL_COMMAND_COPY_BUFFER_RECT,
		USER					= CL_COMMAND_USER,
		GL_FENCE_SYNC_OBJECT	= CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR,		// if cl_khr_gl_event is enabled
	};
}


// ---------------------- Event Profiling Time ------------------- //

namespace cl_event_time
{
	enum	type	: ::cl_profiling_info
	{
		QUEUED	= CL_PROFILING_COMMAND_QUEUED,
		SUBMIT	= CL_PROFILING_COMMAND_SUBMIT,
		START	= CL_PROFILING_COMMAND_START,
		END		= CL_PROFILING_COMMAND_END,
	};
}


// ----------------------- GL Object Type ------------------------ //

namespace cl_gl_object
{
	enum	type	: ::cl_gl_object_type
	{
		BUFFER			= CL_GL_OBJECT_BUFFER,
		TEXTURE_2D		= CL_GL_OBJECT_TEXTURE2D,
		TEXTURE_3D		= CL_GL_OBJECT_TEXTURE3D,
		RENDER_BUFFER	= CL_GL_OBJECT_RENDERBUFFER
	};
}


// ------------------------ Map Buffer Flags --------------------- //

namespace cl_map_flag
{
	enum	type :	::cl_map_flags
	{
		READ	= CL_MAP_READ,
		WRITE	= CL_MAP_WRITE,
	};
}

//-------------------------------------------------------------------

}	// CLShell


UX_ENUM_META_OBJECT( CLShell::cl_queue_property::type );
UX_ENUM_META_OBJECT( CLShell::cl_prog_options::type );
UX_ENUM_META_OBJECT( CLShell::cl_memory::type );
UX_ENUM_META_OBJECT( CLShell::cl_img_channel_order::type );
UX_ENUM_META_OBJECT( CLShell::cl_img_channel::type );
UX_ENUM_META_OBJECT( CLShell::cl_addressing::type );
UX_ENUM_META_OBJECT( CLShell::cl_filter::type );
UX_ENUM_META_OBJECT( CLShell::cl_event_status::type );
UX_ENUM_META_OBJECT( CLShell::cl_event_command::type );
UX_ENUM_META_OBJECT( CLShell::cl_event_time::type );
UX_ENUM_META_OBJECT( CLShell::cl_gl_object::type );
UX_ENUM_META_OBJECT( CLShell::cl_map_flag::type );

//-------------------------------------------------------------------

}	// UX_STL

#endif	// _UXS_CL_ENUMS_H